<template>
  <div class="processRecord">
    <p-table
      size="middle"
      bordered
      rowKey="id"
      :pagination="false"
      :columns="columns"
      :dataSource="tableData"
    >
      <template slot="scientificType" slot-scope="text">
        <span>{{text === '1'?'单盘贴片外协加工':'厂内科研工单'}}</span>
      </template>
    </p-table>
  </div>
</template>
<script>
import process from "@/api/process";
import moment from "moment";
const columns = [
  {
          title: "工单类型",
          align: "center",
          dataIndex: "processType",
          key: "processType",
          customRender: (text) => {
            if (text === 0) {
              return "标准工单";
            } else if (text === 1) {
              return "返修工单";
            } else if (text === 2) {
              return "拆零工单";
            } else if (text === 3) {
              return "改配工单";
            } else if (text === 4) {
              return "中试首样工单";
            } else if (text === 5) {
              return "非常规工单";
            } else if (text === 6) {
              return "中试小批量工单";
            } else if (text === 7) {
              return "工序外协工单";
            } else if (text === 8) {
              return "维修工单";
            } else if (text === 9) {
              return "科研加工工单";
            } else {
              return false;
            }
          },
        },
        {
          title: "任务来源",
          align: "center",
          dataIndex: "taskSource",
          key: "taskSource",
        },
        {
          title: "生产工单",
          align: "center",
          dataIndex: "productionno",
          key: "productionno",
        },
        {
          title: "工序工单",
          align: "center",
          dataIndex: "processbillno",
          key: "processbillno",
        },
        {
          title: "二级工序",
          align: "center",
          dataIndex: "processTwoname",
          key: "processTwoname",
        },
        {
          title: "线体",
          align: "center",
          dataIndex: "lineno",
          key: "lineno",
        },
        {
          title: "产品编码",
          align: "center",
          dataIndex: "productcode",
          key: "productcode",
        },
        {
          title: "产品名称",
          align: "center",
          dataIndex: "productname",
          key: "productname",
        },
        {
          title: "计划数量",
          align: "center",
          dataIndex: "planQty",
          key: "planQty",
        },
        {
          title: "工单状态",
          align: "center",
          dataIndex: "billnoStatus",
          key: "billnoStatus",
          customRender: (text) => {
            if (text === -1) {
              return "已删除";
            } else if (text === 0) {
              return "未发布";
            } else if (text === 1) {
              return "已发布";
            } else if (text === 2) {
              return "已开工";
            } else if (text === 3) {
              return "已暂停";
            }
          },
        },
        {
          title: "物料齐套状态",
          align: "center",
          dataIndex: "qistate",
          key: "qistate",
          customRender: (text) => {
            if (text === 0) {
              return "未齐套";
            } else if (text === 1) {
              return "齐套";
            } else if (text === 2) {
              return "外协已确认";
            } else {
              return false;
            }
          },
        },
        {
          title: "计划开始时间",
          dataIndex: "starttime",
          key: "starttime",
          align: "center",
          customRender: (text) => {
            return moment(text).format("YYYY-MM-DD");
          },
        },
        {
          title: "插单上线审批状态",
          dataIndex: "insertStatas",
          key: "insertStatas",
          align: "center",
          customRender: (text) => {
            if (text === 1) {
              return "审批中";
            } else if (text === 2) {
              return "审批通过";
            }
          },
        },
        {
          title: "缺料上线审批状态",
          dataIndex: "starving",
          key: "starving",
          align: "center",
          customRender: (text) => {
            if (text === 1) {
              return "审批中";
            } else if (text === 2) {
              return "审批通过";
            }
          },
        },
        {
          title: "计划完成时间",
          dataIndex: "completiontime",
          key: "completiontime",
          align: "center",
          customRender: (text) => {
            return moment(text).format("YYYY-MM-DD");
          },
        },
        {
          title: "完成进度",
          dataIndex: "schedule",
          key: "schedule",
          align: "center",
          scopedSlots: {
            customRender: "schedule",
          },
        },
];

export default {
  inject: ["processInstanceId", "taskId", "processDefinitionKey"],
  data() {
    return {
      columns,
      moment,
      readStatusMap: {
        1: "未读",
        2: "已读",
      },
      windowSize: true,
      tableData: [
        /* {
          startTime: '创建时间',
          endTime: '处理时间',
          activityName: '节点名称',
          assigneeName: '执行人',
          readStatus: '1',
          operator: 'operator',
          comment: '处理意见',
        } */
      ],
      tableHeight: "450",
    };
  },
  computed: {},
  methods: {
    getList() {
      if (this.processDefinitionKey == "mfcd") {
        console.log("插单流程");
        process.getExamplemfcdList(this.processInstanceId).then((res) => {
          console.log(res.data);
          this.tableData = [res.data];
        });
      } else if(this.processDefinitionKey =="mfql"){
        console.log("缺料流程");
        process.getExampleqlList(this.processInstanceId).then((res) => {
          console.log(res.data);
          this.tableData = [res.data];
        });
      }
    },
  },
  mounted() {
    this.getList();
  },
};
</script>
<style lang="less">
.processRecord {
  overflow: hidden;
  .handing {
    color: #409efd;
  }
  .title-line {
    font-size: 16px;
    margin: 30px 0 10px 0;
  }
}
</style>
